// 导航守卫
import router from '@/router'
import NProgress from 'nprogress'
import store from '@/store'

const white = ['/login', '/404']

router.beforeEach((to, from, next) => {
  NProgress.start()
  if (store.getters.token) {
    next()
  } else if (white.includes(to.path)) {
    next()
  } else {
    next('/login')
  }
})
router.afterEach((to, from) => {
  NProgress.done()
})
